package concurrent.executeorder;

import org.testng.annotations.Test;
import util.MathUtil;

/**
 * @author zhang peipei
 */
public class ExecuteOrder {

    public static void main(String[] args) {


        for (int i = 0; i < 50; i++) {
            MathUtil.resolvePrime();
            System.out.println("befor " + i);
        }
        System.out.println("before");

        // 执行顺序是下面启动线程并不会和上面的逻辑一起执行
        Runnable r = () -> {
            for (int i = 0; i < 50; i++) {
                System.out.println(MathUtil.resolvePrime());
            }
        };

        new Thread(r).start();
    }


    @Test
    private void t1() {


        for (int i = 0; i < 50; i++) {
            MathUtil.resolvePrime();
            System.out.println("befor " + i);
        }
        System.out.println("before");

        Runnable r = () -> {
            for (int i = 0; i < 50; i++) {
                System.out.println(MathUtil.resolvePrime());
            }
        };

        new Thread(r).start();
    }




}
